package com.yhsimon.iterator;

import java.util.Iterator;

/**
 * @author： YHSimon
 * @date： 2021-10-12 14:35
 */
public class ComputerCollege implements College {
    Department[] departments;
    int numOfDepartment = 0; //保存当前数组的对象个数

    public ComputerCollege() {
        departments = new Department[5];
        addDepartment("Java", "J");
        addDepartment("Python", "P");
        addDepartment("Go", "G");
    }

    @Override
    public String getName() {
        return "计算机学院";
    }

    @Override
    public void addDepartment(String name, String desc) {
        Department department = new Department(name, desc);
        departments[numOfDepartment] = department;
        numOfDepartment++;
    }

    @Override
    public Iterator createIterator() {
        return new ComputerCollegeIterator(departments);
    }
}
